/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package svp;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author kandamaran
 */
@Entity
@Table(name = "product_color_tbl")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ProductColorTbl.findAll", query = "SELECT p FROM ProductColorTbl p"),
    @NamedQuery(name = "ProductColorTbl.findByProductColor", query = "SELECT p FROM ProductColorTbl p WHERE p.productColor = :productColor"),
    @NamedQuery(name = "ProductColorTbl.findByProductCode", query = "SELECT p FROM ProductColorTbl p WHERE p.productCode = :productCode")})
public class ProductColorTbl implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "product_color")
    private String productColor;
    @Basic(optional = false)
    @Column(name = "product_code")
    private String productCode;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "productColor")
    private Collection<ProductUnitTbl> productUnitTblCollection;

    public ProductColorTbl() {
    }

    public ProductColorTbl(String productColor) {
        this.productColor = productColor;
    }

    public ProductColorTbl(String productColor, String productCode) {
        this.productColor = productColor;
        this.productCode = productCode;
    }

    public String getProductColor() {
        return productColor;
    }

    public void setProductColor(String productColor) {
        this.productColor = productColor;
    }

    public String getProductCode() {
        return productCode;
    }

    public void setProductCode(String productCode) {
        this.productCode = productCode;
    }

    @XmlTransient
    public Collection<ProductUnitTbl> getProductUnitTblCollection() {
        return productUnitTblCollection;
    }

    public void setProductUnitTblCollection(Collection<ProductUnitTbl> productUnitTblCollection) {
        this.productUnitTblCollection = productUnitTblCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (productColor != null ? productColor.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProductColorTbl)) {
            return false;
        }
        ProductColorTbl other = (ProductColorTbl) object;
        if ((this.productColor == null && other.productColor != null) || (this.productColor != null && !this.productColor.equals(other.productColor))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "svp.ProductColorTbl[ productColor=" + productColor + " ]";
    }
    
}
